package com.lanou.sinasports.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.lanou.sinasports.R;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by dllo on 16/1/12.
 */
public class DrawAdapter extends BaseAdapter {
    private Context context;
    private List<String> data;

    public DrawAdapter(Context context) {
        this.context = context;
        initData();
    }

    private void initData() {
        data=new ArrayList<>();
        data.add("消息盒子");
        data.add("竞猜");
        data.add("比赛筛选");
        data.add("提醒设置");
        data.add("更多设置");
        data.add("应用中新");

    }

    @Override
    public int getCount() {
        return data.size();
    }

    @Override
    public Object getItem(int position) {
        return data.get(position);
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        MyViewHolder myViewHolder;
        if(convertView==null){
            convertView=LayoutInflater.from(context).inflate(R.layout.item_draw,null);
            myViewHolder=new MyViewHolder(convertView);
            convertView.setTag(myViewHolder);
        }else {
            myViewHolder= (MyViewHolder) convertView.getTag();
        }
        myViewHolder.textView.setText(data.get(position));
        return convertView;
    }

    class MyViewHolder{
        TextView textView;

        public MyViewHolder(View view) {
            textView= (TextView) view.findViewById(R.id.tv_item_draw);
        }
    }

}
